package com.seven.wxmessagepush.controller;

import com.seven.wxmessagepush.entity.Custom;
import com.seven.wxmessagepush.entity.ImageMessage;
import com.seven.wxmessagepush.entity.TextMeaasge;
import com.seven.wxmessagepush.utils.SendDataUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author:Seven Description:
 * @Date:Created at 2022/8/17 11:22
 */
@RestController
public class WxMessagePushController {


    /**
     * 自定义请求方式
     * @param custom
     * @return
     */
    @PostMapping("/sendMessage")
    public String sendMessagePost(@RequestBody Custom custom) {
        return new SendDataUtil().sendPost(custom.getUrl(), custom.getParam());
    }

    /**
     * 推送文字消息接口
     * @param textMeaasge
     * @return
     */
    @PostMapping("/sendTextMessage")
    public String sendTextMessagePost(@RequestBody TextMeaasge textMeaasge) {
        return new SendDataUtil().sendTextData(textMeaasge);
    }

    /**
     * 推送News消息接口
     * @param textMeaasge
     * @return
     */
    @PostMapping("/sendNewsMessage")
    public String sendNewsMessagePost(@RequestBody TextMeaasge textMeaasge) {
        return new SendDataUtil().sendNewsData(textMeaasge);
    }

    /**
     * 推送Markdown消息接口
     * @param textMeaasge
     * @return
     */
    @PostMapping("/sendMarkdownMessage")
    public String sendMarkdownMessagePost(@RequestBody TextMeaasge textMeaasge) {
        return new SendDataUtil().sendMarkdownData(textMeaasge);
    }

    /**
     * 推送图片消息接口
     * @param imageMessage
     * @return
     */
    @PostMapping("/sendImageMessage")
    public String sendImageMessagePost(@RequestBody ImageMessage imageMessage) {

        String str = "## 警告\n" +
                "\n" +
                "<font color=\"red\">"+"测试警告"+"</font>\n" +
                "\n" +
                ">  奥特维焊机状态异常\n" +
                "> \n" +
                ">  流水线数据丢失\n";
        return new SendDataUtil().sendImageData(imageMessage);

    }

}
